package cn.manyufun.myf.ui.main.presenter;

import cn.manyufun.myf.R;
import cn.manyufun.myf.app.AppConstant;
import cn.manyufun.myf.bean.BaseBean;
import cn.manyufun.myf.bean.FollowListBean;
import cn.manyufun.myf.common.baserx.RxSubscriber;
import cn.manyufun.myf.ui.main.contract.CollectionListContract;
import rx.functions.Action1;

/**
 * Created by Xiao on 2018-01-31.
 */

public class CollectionListPresenter extends CollectionListContract.Presenter {
    @Override
    public void onStart() {
        super.onStart();
        //新增说说监听
        mRxManage.on(AppConstant.COLLECTION_ON_LOGOUT, new Action1<BaseBean>() {
            @Override
            public void call(BaseBean baseBean) {
                mView.onLogout();
            }
        });
    }

    @Override
    public void loadFollowListRequest(int pageIndex, int pageSize) {
        mRxManage.add(mModel.loadFollowList(pageIndex, pageSize)
                .subscribe(new RxSubscriber<FollowListBean>(mContext, false) {
                    @Override
                    public void onStart() {
                        super.onStart();
                        mView.showLoading(mContext.getString(R.string.loading));
                    }

                    @Override
                    protected void _onNext(FollowListBean followListBean) {
                        mView.returnFollowList(followListBean);
                        mView.stopLoading();
                    }

                    @Override
                    protected void _onError(String message) {
                        mView.showErrorTip(message);
                    }
                }));
    }
}
